package Thread_;

public class Thread06 {
    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run() {
                while(true){
                    System.out.println("Thread run06");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        System.out.println("start之前");
        thread.setDaemon(true);//在start之前,设置线程为后台线程
        thread.start();
        System.out.println("start之后");
        System.out.println("main");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("main之后");

//        while(true){
//            System.out.println("main");
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        }


    }
}
